﻿@implements IDisposable
@inject GlobalConfig GlobalConfig;

<MOverlay ZIndex=9999999 Value="IsLoading">
    <MProgressCircular Indeterminate Size="64"></MProgressCircular>
</MOverlay>

@code {
    [Parameter]
    public bool IsLoading { get; set; }

    [Parameter]
    public EventCallback<bool> LoadingChanged { get; set; }

    void Loading(bool loading)
    {
        IsLoading = loading;
        base.StateHasChanged();
    }

    protected override void OnInitialized()
    {
        GlobalConfig.OnLoadingChanged += Loading;
    }

    public void Dispose()
    {
        GlobalConfig.OnLoadingChanged -= Loading;
    }
}